/*
 * Грузовик
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include <string.h>
#include <limits.h>
#include <stdint.h>

#ifdef DEBUG
# define debug_fprintf(x)	fprintf x
#else
# define debug_fprintf(x)	((void) 0)
#endif

#define MAX(a, b)	((a) > (b) ? (a) : (b))
#define MIN(a, b)	((a) < (b) ? (a) : (b))

/* {{{ memory allocation wrappers */
extern void *s_calloc(size_t n, size_t size)
{
	void *ptr;
	ptr = calloc(n, size);
	assert(ptr != NULL);
	if (ptr == NULL) {
		debug_fprintf((stderr, "out of memory\n"));
		abort();
	}
	return ptr;
}

extern void *s_malloc(size_t size)
{
	void *ptr;
	ptr = malloc(size);
	assert(ptr != NULL);
	if (ptr == NULL) {
		debug_fprintf((stderr, "out of memory\n"));
		abort();
	}
	return ptr;
}
/* }}} */

/* {{{ autoarray */
struct vector {
	int *data;
	int n;
	int max;
};
/* {{{ functions */
extern int
vector_init(struct vector *v, int p)
{
	if (v == NULL) {
		fprintf(stderr, "vector_init(): received NULL ptr, not doing anything\n");
		return 1;
	}

	if (p < 0 || p >= (CHAR_BIT * sizeof v->data[0]))
		p = 0;
	v->max = 1 << p;
	v->n = 0;
	v->data = (int *) s_calloc((size_t) v->max, sizeof *v->data);

	return 0;
}

extern int
vector_append(struct vector *v, int a)
{
	int *t = NULL;

	if (v == NULL) {
		fprintf(stderr, "vector_append(): received NULL ptr, not doing anything\n");
		return 1;
	}

	if (v->max == 0)
		vector_init(v, 0);

	if (v->n + 1 > v->max) {
		t = (int *) realloc(v->data, sizeof *t * (v->max *= 2));
		if (!t) {
			fprintf(stderr, "vector_append(): failed to allocate %d bytes\n", v->max);
			return 1;
		} else {
			v->data = t;
		}
	}

	v->data[v->n++] = a;

	return 0;
}

extern int
vector_sort(struct vector *v, int (*cmpf)(const void *, const void *))
{
	if (v == NULL) {
		fprintf(stderr, "vector_sort(): received NULL ptr, not doing anything\n");
		return 1;
	}

	if (v->max > 0 && v->n > 1) {
		qsort(v->data, (size_t) v->n, sizeof *v->data, cmpf);
		return 0;
	} else {
		return 1;
	}
}

extern int
vector_cleanup(struct vector *v)
{
	if (v == NULL) {
		fprintf(stderr, "vector_cleanup(): received NULL ptr, not doing anything\n");
		return 1;
	}

	if (v->max > 0) {
		v->max = v->n = 0;
		free(v->data);
		v->data = NULL;
		return 0;
	} else {
		return 1;
	}
}
/* }}} */
/* }}} */

/* {{{ doubly-linked list */
struct dll_node {
	int x, y;
	char *data;
	size_t _data_size;
	struct dll_node *prev, *next;
};
/* {{{ functions */
/*
 * This function inserts one node pointed to by 'ins' _after_ 'node'.
 */
extern struct dll_node *
dll_insert(struct dll_node *node, struct dll_node *ins)
{
	assert(node != NULL);
	if (ins == NULL) {
		debug_fprintf((stderr, "dll_insert(): ins is NULL, not doing anything\n"));
		return node;
	}

	if (node->next) {
		assert(node->next->prev == node);
		node->next->prev = ins;
	}
	ins->next = node->next;
	ins->prev = node;
	node->next = ins;
	return ins;
}

/*
 * This function extracts 'node' from a doubly-linked list and returns pointer
 * to that node, pointers '->prev' and '->next' are not reset.
 *
 * If you really want to get rid of a node, call
 * 	free(dll_delete(unneeded_node));
 */
extern struct dll_node *
dll_delete(struct dll_node *node)
{
	if (!node) {
		debug_fprintf((stderr, "dll_delete(): received NULL ptr, wtf am i supposed to delete?\n"));
		return NULL;
	}

	if (node->prev) {
		assert(node->prev->next == node);
		node->prev->next = node->next;
	}
	if (node->next) {
		assert(node->next->prev == node);
		node->next->prev = node->prev;
	}

	return node;
}

/*
 * Merge-sort for doubly-linked list.
 *
 * TODO: work out the use of (*cmp)() function
 */
extern void
dll_mergesort(struct dll_node *head, int (*cmp)(const void *, const void *))
{
	struct dll_node *end, *mid;
	struct dll_node *sorted, *first, *second;
	struct dll_node *swap;

	if (head == NULL || head->next == NULL) /* lengths 0, 1 */
		return;

	end = mid = head;
	while (end && end->next && end->next->next) {
		end = end->next->next;
		mid = mid->next;
	}
	if (end && end->next) {
		end = end->next;
		mid = mid->next;
	}

	mid->prev->next = NULL;
	mid->prev = NULL;
	dll_mergesort(head, cmp);
	dll_mergesort(mid, cmp);

	if (cmp(head->data, mid->data) > 0) { /* this is the tricky part */
		char *t1;
		size_t t2;
		struct dll_node *t3;
		int t4;
#define SWAP_(a,b,t) do{(t)=(a),(a)=(b),(b)=(t);}while(0)
		if (head->next && mid->next)
			SWAP_(head->next->prev, mid->next->prev, t3);
		SWAP_(head->x, mid->x, t4);
		SWAP_(head->data, mid->data, t1);
		SWAP_(head->_data_size, mid->_data_size, t2);
		SWAP_(head->prev, mid->prev, t3);
		SWAP_(head->next, mid->next, t3);
#undef SWAP_
	}

	/*
	 * from now on using only ->prev and ->next pointers should suffice us
	 */
	first = head->next;
	if (first) first->prev = NULL;
	second = mid;

	sorted = head;
	sorted->next = NULL;
	assert(sorted->prev == NULL);

	while (first && second) {
		assert(sorted->next == NULL);

		/* TODO: un-copypaste this code (use 'swap' ptr) */
		if (cmp(first->data, second->data) < 0)
			swap = first;
		else
			swap = second;

		assert(swap->prev == NULL);

		sorted->next = swap;
		swap->prev = sorted;
		sorted = swap;

		swap = swap->next;
		if (swap) {
			assert(swap->prev == sorted);
			swap->prev->next = NULL;
			swap->prev = NULL;
		}
	}
	assert(sorted->next == NULL);
	if (first) {
		assert(first->prev == NULL);
		sorted->next = first;
		first->prev = sorted;
	}
	if (second) {
		assert(second->prev == NULL);
		sorted->next = second;
		second->prev = sorted;
	}
}
/* }}} */
/* }}} */

/* {{{ graph repr: adjlist w/ doubly-linked list */
enum vertex_st {
	VTX_ST_UNKN = 0,
	VTX_ST_OPEN,
	VTX_ST_VISITED
};

struct adjlist_dll {
	struct dll_node *head;
	struct dll_node *tail;
	size_t _list_len;

	enum vertex_st state;
	int color;
	int distance;
	int parent;
	int fwd, bck; /* dfs tree depth, >=1 unless uninitialized */
	int low; /* lowpoint(), >=1 unless uninitialized */
	int chnum; /* children count for this node */
};
/* {{{ functions */
extern void
adjl_dll_connect(struct adjlist_dll *node, const int conid, const int edgeid)
{
	struct dll_node *Wilson;

	Wilson = (struct dll_node *) s_calloc(1, sizeof *Wilson);
	Wilson->x = conid;
	Wilson->y = edgeid;
	Wilson->prev = Wilson->next = NULL;

	if (node->head == NULL) {
		assert(node->tail == NULL);
		node->head = node->tail = Wilson;
		node->_list_len = 1;
	} else {
		node->tail = dll_insert(node->tail, Wilson);
		node->_list_len++;
	}
}

extern void
adjl_dll_cleanup(struct adjlist_dll *al)
{
	struct dll_node *nx = al->head, *pr = al->head;

	while (nx) {
		pr = nx;
		nx = nx->next;
		free(pr);
	}
	al->_list_len = 0;
	al->head = al->tail = NULL;
}
/* }}} */
/* }}} */

int
dfs_find_path(int *am, const int n, const int w, const int s, const int t,
		int *path, int8_t *st)
{
	int i;
	int ans = 0;

	st[s] = 1;
	for (i = 0; i < n; i++) {
		if (am[s * n + i] > 0 && am[s * n + i] >= w && st[i] == 0) {
			if (i == t) {
				path[s] = t;
				return 1;
			} else {
				if (dfs_find_path(am, n, w, i, t, path, st) == 1) {
					ans = 1;
					path[s] = i;
					break;
				}
			}
		}
	}
	st[s] = 2;

	return ans;
}

int
main(int argc, char **argv)
{
	int n, m, w, s, t;
	int u, v, ew;
	static int am[1000][1000];
	int i;
	int len;
	static int path[1000];
	static int8_t st[1000];

	scanf("%d %d %d %d %d", &n, &m, &w, &s, &t);
	--s; --t;
	for (i = 0; i < m; i++) {
		scanf("%d %d %d", &u, &v, &ew);
		--u; --v;
		am[u][v] = am[v][u] = ew;
	}

	if (dfs_find_path(&am[0][0], 1000, w, s, t, path, st) != 1) {
		puts("0");
	} else {
		i = s;
		len = 1;
		do {
			++len;
			i = path[i];
		} while (path[i] != t);
		printf("%d\n", len + 1);
		i = s;
		do {
			printf("%d ", i + 1);
			i = path[i];
		} while (i != t);
		printf("%d\n", t + 1);
	}

	return 0;
}
